﻿// Services/ChatService.cs
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BlazorWebAppMovies.Services
{
   

    public class ChatService
    {
        // 存储历史消息
        public List<(string User, string Message)> Messages { get; } = new();

        // 定义事件委托，用于通知新消息
        public event Action<string, string>? MessageReceived;

        // 发送消息并触发事件
        public async Task SendMessageAsync(string user, string message)
        {
            Messages.Add((user, message));
            MessageReceived?.Invoke(user, message); // 通知所有订阅的组件
        }
    }
}
